package com.eax.ControlLayer;
import com.eax.ModelLayer.*;
import java.util.ArrayList;

public class ReservationController {
	ReservationCollectionModel reservationCollection;

	public ReservationController(){
		reservationCollection = new ReservationCollectionModel();
	}

	public void addReservation(int id, int personID, int DVDID, String status, String reservationDate){
		reservationCollection.addReservation(id, personID, DVDID, status, reservationDate);
	}

	public ReservationModel getReservationById(int id){
		ReservationModel i = null;
		for(ReservationModel l : reservationCollection.getAllReservations()){
			if(l.getId() == id){
				i = l;
			}
		}

		return i;
	}

	public ReservationModel getReservationModel(int id){
		return reservationCollection.getReservationById(id);
	}

	public int getHighestId(){
		int i = 0;

		for(ReservationModel c : reservationCollection.getAllReservations()){
			if(c.getId() > i){
				i = c.getId();
			}
		}

		return i;
	}

	public ArrayList<ReservationModel> getAllReservations(){
		return reservationCollection.getAllReservations();
	}

	public void removeReservation(int id){
		ReservationModel reservation = reservationCollection.getReservationById(id);
		reservationCollection.removeReservation(reservation);

	}
}